from django.conf.urls.defaults import *
from django.conf import settings
from seriesapp.feeds import LatestEntriesFeed
from haystack.forms import ModelSearchForm
from haystack.views import SearchView
from seriesapp.buscar import MiQueryModificada

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',
        # Example:
        # (r'^series/', include('series.foo.urls')),
        
        # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
        # to INSTALLED_APPS to enable admin documentation:
        # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
        
        # Mis templates.
        (r'^series/$', 'seriesapp.views.index'),
        #(r'^series/(?P<serie_slug>)/episode/(?P<episode_id>\d+)/$', 'series.seriesapp.views.detail_episode'),
        (r'^series/(?P<serie_slug>[a-zA-Z0-9_.-]+)/$', 'seriesapp.views.detail'),
        #(r'^series/(?P<serie_slug>[a-zA-Z0-9_.-]+)/episodes/$', 'series.seriesapp.views.detail'),
        (r'^series/(?P<serie_slug>[a-zA-Z0-9_.-]+)/episode/(?P<episode_id>\d+)/$', 'seriesapp.views.detail_episode'),
        
        # Plantillas cargadas
        (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_DIR}),
        (r'^i18n/', include('django.conf.urls.i18n')),
        (r'^comments/', include('django.contrib.comments.urls')),
        
        # RSS
        (r'^feeds/$', LatestEntriesFeed()),

        # js
        #(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'media/js'}),
        
        # Uncomment the next line to enable the admin:
        url(r'^admin/', include(admin.site.urls)),
        
        # esto redirecciona la raiz
        (r'^$', 'seriesapp.views.index'),

)

if 'rosetta' in settings.INSTALLED_APPS:
    urlpatterns += patterns('',
        url(r'^rosetta/', include('rosetta.urls')),
    )

if 'haystack' in settings.INSTALLED_APPS:
        urlpatterns += patterns('haystack.views',
                url(r'^search/$', 
                        SearchView(
                                searchqueryset=MiQueryModificada(),
                                form_class=ModelSearchForm
                        ), name='haystack_search_ml'
                ),
        )